
# 页面类
from Base import Base
from selenium.webdriver.common.by import By

class Page(Base):
    # 定义页面元素定位器
    username_loc = (By.NAME, 'loginName')
    password_loc = (By.NAME, 'roncooPwd')
    login_loc = (By.XPATH, '/html/body/div/div[2]/div[1]/form/div[3]/input')
    pay_loc = (By.XPATH, '//*[@id="sidebar"]/div[2]/div[7]/h2')
    pro_ductlist_loc = (By.CSS_SELECTOR, '#sidebar > div.accordion.dwz-accordion > div:nth-child(8) > ul > li:nth-child(1) > div > a')
    pay_ductname_loc = (By.CLASS_NAME, 'textInput')
    search_loc = (By.XPATH, '//*[@id="navTab"]/div[2]/div[2]/div[1]/form/div/table/tbody/tr/td[2]/div/div/button')

    # 输入用户名
    def username(self):
        self.send_keys(self.username_loc, 'admin')

    # 输入密码
    def password(self):
        self.send_keys(self.password_loc, '123456')

    # 点击登录按钮
    def login(self):
        self.click(self.login_loc)

    # 点击支付管理
    def pay(self):
        self.click(self.pay_loc)

    # 点击支付产品信息
    def producklist(self):
        self.click(self.pro_ductlist_loc)

    # 输入产品名称进行搜索
    def payductname(self):
        self.send_keys(self.pay_ductname_loc, 'python基础第一章')

    # 点击搜索按钮
    def search(self):
        self.click(self.search_loc)